package com.tt.jshb.order;

import android.graphics.Color;
import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hzecool.common.utils.ResourceUtils;
import com.tt.jshb.R;
import com.tt.jshb.bean.RecycleHistoryBean;

import java.util.List;

/**
 * @author tutu
 * @time 2018/6/8
 */

public class HistoryAdapter extends BaseQuickAdapter<RecycleHistoryBean.DataBean, BaseViewHolder> {

    public HistoryAdapter(List<RecycleHistoryBean.DataBean> data) {
        super(R.layout.history_list_item, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, RecycleHistoryBean.DataBean item) {
        String dis1 = "应还"+item.getJkje()+"元";
        String dis2 = "借款"+item.getJkje()+"元"+" "+item.getTs()+"天";

        helper.setText(R.id.tv_1, dis1)
                .setText(R.id.tv_time_money, dis2)
                .setText(R.id.tv_endtime,TextUtils.isEmpty(item.getEndtimes()) ? "--  --" : item.getEndtimes());

        helper.setTextColor(R.id.tv_2, ResourceUtils.getColor(R.color.grey))
                .setTextColor(R.id.tv_1, ResourceUtils.getColor(R.color.grey))
                .setTextColor(R.id.tv_time_money, ResourceUtils.getColor(R.color.grey))
                .setTextColor(R.id.tv_endtime, ResourceUtils.getColor(R.color.grey));

        if (0 == item.getMark()) {
            helper.setText(R.id.tv_3, "新申请");
            helper.setTextColor(R.id.tv_3, Color.BLUE);
        } else if (1 == item.getMark()) {
            helper.setText(R.id.tv_3, "通过");
            helper.setTextColor(R.id.tv_3, Color.GREEN);
            helper.setTextColor(R.id.tv_2, ResourceUtils.getColor(R.color.black))
                    .setTextColor(R.id.tv_time_money, ResourceUtils.getColor(R.color.black))
                    .setTextColor(R.id.tv_1, ResourceUtils.getColor(R.color.black))
                    .setTextColor(R.id.tv_endtime, ResourceUtils.getColor(R.color.black));
            helper.addOnClickListener(R.id.root);
        } else if (2 == item.getMark()) {
            helper.setText(R.id.tv_3, "申请未通过");
            helper.setTextColor(R.id.tv_3, Color.GRAY);
        } else if (3 == item.getMark()) {
            helper.setText(R.id.tv_3, "已完结");
            helper.setTextColor(R.id.tv_3, Color.GRAY);
        } else if (4 == item.getMark()) {
            helper.setText(R.id.tv_3, "取消");
            helper.setTextColor(R.id.tv_3, Color.GRAY);
        } else if (5 == item.getMark()) {
            helper.setText(R.id.tv_3, "申请审核中");
            helper.setTextColor(R.id.tv_3, Color.parseColor("#783202"));
        }
    }
}
